"""
基础插件类
定义所有插件的基类和接口
"""

from abc import ABC, abstractmethod
from typing import Dict, Any, List
import logging
import json


class BasePlugin(ABC):
    """插件基类"""
    
    def __init__(self, config: Dict[str, Any]):
        self.config = config
        self.logger = logging.getLogger(self.__class__.__name__)
        self.name = config.get("name", self.__class__.__name__)
        self.version = config.get("version", "1.0.0")
        self.enabled = config.get("enabled", True)
    
    @abstractmethod
    async def initialize(self) -> bool:
        """初始化插件"""
        pass
    
    @abstractmethod
    async def execute(self, data: Dict[str, Any]) -> Dict[str, Any]:
        """执行插件功能"""
        pass
    
    async def cleanup(self):
        """清理资源"""
        pass
    
    def get_info(self) -> Dict[str, Any]:
        """获取插件信息"""
        return {
            "name": self.name,
            "version": self.version,
            "type": self.__class__.__name__,
            "enabled": self.enabled
        }